package com.qfedu.rocketmq01.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 千锋Java,为你而生！
 *
 * @Author: Feri
 * @Date:2024/11/14 10:02
 * @Modified:
 */
@RestController
@RequestMapping("api/tran")
@Slf4j
@Tag(name = "事务消息发送")
public class MqTranController {
    @Resource
    private RocketMQTemplate template;

    @GetMapping("send1")
    public String send1(String msg){
        //1.发送事务消息
        Message message= MessageBuilder.withPayload(msg).build();
        template.sendMessageInTransaction("xingmq01",message,null);
        return "OK";
    }
}
